package cn.tedu.boot23.controller;

import cn.tedu.boot23.entity.Hero;
import cn.tedu.boot23.mapper.HeroMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

@RestController
//此注解相当于在每个方法上面都添加了@ResponseBody注解
public class HeroController {
    @Autowired
    HeroMapper mapper;
    @RequestMapping("/add")
    @ResponseBody
    public String add(Hero hero){
        System.out.println("hero. = " + hero);
        mapper.insert(hero);
        return "添加完成!";
    }
}
